{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# defining diagonal quadratic form f with coefficients given by coeff\n",
    "#\n",
    "def f(coeff, v):\n",
    "    return sum([c*v^2 for (c,v) in zip(coeff, v)]);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# defining associated bilinear form\n",
    "#\n",
    "def b(coeff, u, v):\n",
    "    return 1/2*(f(coeff, u+v) - f(coeff, u) - f(coeff, v));"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# defining the reflection in the hyperplane with normal u\n",
    "# this reflection belongs to O(f) as above\n",
    "#\n",
    "def ref(coeff, u):\n",
    "    n = len(coeff);\n",
    "    v = matrix.identity(n);\n",
    "    return matrix([v[i] - 2*b(coeff, v[i], u)/f(coeff, u)*u for i in range(n)]).transpose();"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# computing the order of a matrix m after reduction modulo ideal J = (p) generated by a positive integer p\n",
    "#\n",
    "def matrix_reduction_order(m, p, max_iter=1E4):\n",
    "    k = 1;\n",
    "    l1 = l2 = m.apply_map(lambda x: mod(x, p));\n",
    "    while not(l2==matrix.identity(m.nrows())) and (k < max_iter):\n",
    "        k = k+1;\n",
    "        l2 = (l1*l2).apply_map(lambda x: mod(x, p));\n",
    "    return k;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# dimension = 4\n",
    "#\n",
    "# basis vectors\n",
    "#\n",
    "v = matrix.identity(5);\n",
    "#\n",
    "# coefficients of the quadratic form\n",
    "#\n",
    "f4 = [-1] + 4*[1];"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# outer normals for the polytope P_4\n",
    "#\n",
    "e1 = -v[1];\n",
    "e2 = -v[2];\n",
    "e3 = -v[3];\n",
    "e4 = -v[4];\n",
    "e5 = v[0] + v[1] + v[2];\n",
    "e6 = v[0] + v[3] + v[4];"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# reflections in the hyperplanes of P_4\n",
    "#\n",
    "s1 = ref(f4, e1);\n",
    "s2 = ref(f4, e2);\n",
    "s3 = ref(f4, e3);\n",
    "s4 = ref(f4, e4);\n",
    "s5 = ref(f4, e5);\n",
    "s6 = ref(f4, e6);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# uncomment the following lines to see the reflection matrices\n",
    "#"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# show(\"s1 = \", s1);\n",
    "# show(\"s2 = \", s2);\n",
    "# show(\"s3 = \", s3);\n",
    "# show(\"s4 = \", s4);\n",
    "# show(\"s5 = \", s5);\n",
    "# show(\"s6 = \", s6);\n",
    "#"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\verb|delta4|\\phantom{\\verb!x!}\\verb|=| \\left(\\begin{array}{rrrrr}\n",
       "3 & -2 & -2 & 0 & 0 \\\\\n",
       "-2 & 1 & 2 & 0 & 0 \\\\\n",
       "-2 & 2 & 1 & 0 & 0 \\\\\n",
       "0 & 0 & 0 & 1 & 0 \\\\\n",
       "0 & 0 & 0 & 0 & 1\n",
       "\\end{array}\\right)</script></html>"
      ],
      "text/plain": [
       "'delta4 = ' [ 3 -2 -2  0  0]\n",
       "[-2  1  2  0  0]\n",
       "[-2  2  1  0  0]\n",
       "[ 0  0  0  1  0]\n",
       "[ 0  0  0  0  1]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#\n",
    "# an infinite order orientation-reversing element in \\Gamma \\cap \\Delta\n",
    "#\n",
    "delta4 = s1*s2*s5;\n",
    "show(\"delta4 = \", delta4);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[-1, 1, 1, 0.1715728752538099?, 5.828427124746190?]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "delta4.eigenvalues()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#\n",
    "# the order of the reduction of \\delta_4 modulo (3)\n",
    "#\n",
    "matrix_reduction_order(delta4, 3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2^2"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#\n",
    "# its prime factors\n",
    "#\n",
    "factor(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#\n",
    "# the order of the reduction of \\delta_4 modulo (4)\n",
    "#\n",
    "matrix_reduction_order(delta4, 4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#\n",
    "# its prime factors\n",
    "#\n",
    "factor(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# dimensions n = 5 through 8: c.f. manuscript \n",
    "# the orders of reductions will be exactly the same since \\delta_n extends \\delta_4 trivially by the identity map\n",
    "#"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# dimension = 9\n",
    "#\n",
    "# basis vectors\n",
    "#\n",
    "v = matrix.identity(10);\n",
    "#\n",
    "# coefficients of the quadratic form\n",
    "#\n",
    "f9 = [-2] + 9*[1];"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# outer normals for the polytope P_9\n",
    "#\n",
    "e1 = -v[1] + v[2]; \n",
    "e2 = -v[2] + v[3];\n",
    "e3 = -v[3] + v[4];\n",
    "e4 = -v[4] + v[5];\n",
    "e5 = -v[5] + v[6];\n",
    "e6 = -v[6] + v[7];\n",
    "e7 = -v[7] + v[8];\n",
    "e8 = -v[8] + v[9];\n",
    "e9 = -v[9];\n",
    "e10 = v[0] + 2*v[1];\n",
    "e11 = v[0] + v[1] + v[2] + v[3] + v[4];\n",
    "e12 = 2*v[0] + v[1] + v[2] + v[3] + v[4] + v[5] + v[6] + v[7] + v[8] + v[9];"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# reflections in the hyperplanes of P_9\n",
    "#\n",
    "s1  = ref(f9, e1);\n",
    "s2  = ref(f9, e2);\n",
    "s3  = ref(f9, e3);\n",
    "s4  = ref(f9, e4);\n",
    "s5  = ref(f9, e5);\n",
    "s6  = ref(f9, e6);\n",
    "s7  = ref(f9, e7);\n",
    "s8  = ref(f9, e8);\n",
    "s9  = ref(f9, e9);\n",
    "s10 = ref(f9, e10);\n",
    "s11 = ref(f9, e11);\n",
    "s12 = ref(f9, e12);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# uncomment the following lines to see the reflection matrices\n",
    "#"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# show(\"s1 = \", s1);\n",
    "# show(\"s2 = \", s2);\n",
    "# show(\"s3 = \", s3);\n",
    "# show(\"s4 = \", s4);\n",
    "# show(\"s5 = \", s5);\n",
    "# show(\"s6 = \", s6);\n",
    "# show(\"s7 = \", s7);\n",
    "# show(\"s8 = \", s8);\n",
    "# show(\"s9 = \", s9);\n",
    "# show(\"s10 = \", s10);\n",
    "# show(\"s11 = \", s11);\n",
    "# show(\"s12 = \", s12);\n",
    "#"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\verb|delta9|\\phantom{\\verb!x!}\\verb|=| \\left(\\begin{array}{rrrrrrrrrr}\n",
       "3 & -1 & -1 & -1 & -1 & 0 & 0 & 0 & 0 & 0 \\\\\n",
       "0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n",
       "2 & 0 & -1 & -1 & -1 & 0 & 0 & 0 & 0 & 0 \\\\\n",
       "2 & -1 & 0 & -1 & -1 & 0 & 0 & 0 & 0 & 0 \\\\\n",
       "2 & -1 & -1 & 0 & -1 & 0 & 0 & 0 & 0 & 0 \\\\\n",
       "2 & -1 & -1 & -1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n",
       "0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n",
       "0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n",
       "0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n",
       "0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\n",
       "\\end{array}\\right)</script></html>"
      ],
      "text/plain": [
       "'delta9 = ' [ 3 -1 -1 -1 -1  0  0  0  0  0]\n",
       "[ 0  0  0  0  0  0  0  0  0  1]\n",
       "[ 2  0 -1 -1 -1  0  0  0  0  0]\n",
       "[ 2 -1  0 -1 -1  0  0  0  0  0]\n",
       "[ 2 -1 -1  0 -1  0  0  0  0  0]\n",
       "[ 2 -1 -1 -1  0  0  0  0  0  0]\n",
       "[ 0  0  0  0  0  1  0  0  0  0]\n",
       "[ 0  0  0  0  0  0  1  0  0  0]\n",
       "[ 0  0  0  0  0  0  0  1  0  0]\n",
       "[ 0  0  0  0  0  0  0  0  1  0]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#\n",
    "# an infinite order orientation-reversing element in \\Gamma \\cap \\Delta\n",
    "#\n",
    "delta9 = s1*s2*s3*s4*s5*s6*s7*s8*s11;\n",
    "show(\"delta9 = \", delta9);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, -1, 0.7808606944168846?, 1.280638156267758?, -0.8820074625972912? - 0.4712354357671843?*I, -0.8820074625972912? + 0.4712354357671843?*I, -0.3469112282522566? - 0.9378979687111550?*I, -0.3469112282522566? + 0.9378979687111550?*I, 0.1981692655072266? - 0.9801678132892991?*I, 0.1981692655072266? + 0.9801678132892991?*I]"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "delta9.eigenvalues()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "84"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#\n",
    "# the order of the reduction of \\delta_9 modulo (3)\n",
    "#\n",
    "matrix_reduction_order(delta9, 3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2^2 * 3 * 7"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#\n",
    "# its prime factors\n",
    "#\n",
    "factor(84)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "34"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#\n",
    "# the order of the reduction of \\delta_9 modulo (4)\n",
    "#\n",
    "matrix_reduction_order(delta9, 4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2 * 17"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#\n",
    "# its prime factors\n",
    "#\n",
    "factor(34)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# dimensions n = 10 and 13: c.f. manuscript \n",
    "# the orders of reductions will be exactly the same since \\delta_n extends \\delta_9 trivially by the identity map\n",
    "#"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# dimension = 11\n",
    "#\n",
    "# basis vectors\n",
    "#\n",
    "v = matrix.identity(12);\n",
    "#\n",
    "# coefficients of the quadratic form\n",
    "#\n",
    "f11 = [-2] + 8*[1] + 3*[2];"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# outer normals for the polytope P_11\n",
    "#\n",
    "e1 = -v[1] + v[2]; \n",
    "e2 = -v[2] + v[3];\n",
    "e3 = -v[3] + v[4];\n",
    "e4 = -v[4] + v[5];\n",
    "e5 = -v[5] + v[6];\n",
    "e6 = -v[6] + v[7];\n",
    "e7 = -v[7] + v[8];\n",
    "e8 = -v[8];\n",
    "e9 = -v[9] + v[10];\n",
    "e10 = -v[10] + v[11];\n",
    "e11 = -v[11];\n",
    "e12 = v[0] + v[9] + v[10] + v[11];\n",
    "e13 = v[0] + 2*v[1] + v[9];\n",
    "e14 = v[0] + v[1] + v[2] + v[3] + v[4];\n",
    "e15 = 2*v[0] + v[1] + v[2] + v[3] + v[4] + v[5] + v[6] + v[9] + v[10];\n",
    "e16 = 2*v[0] + v[1] + v[2] + v[3] + v[4] + v[5] + v[6] + v[7] + v[8] + v[9];\n",
    "e17 = 3*v[0] + 2*(v[1] + v[2]) + v[3] + v[4] + v[5] + v[6] + v[7] + v[8] + v[9] + v[10] + v[11];\n",
    "e18 = 4*v[0] + 2*(v[1] + v[2] + v[3] + v[4] + v[5] + v[6] + v[7]) + v[9] + v[10] + v[11];"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# reflections in the hyperplanes of P_11\n",
    "#\n",
    "s1  = ref(f11, e1);\n",
    "s2  = ref(f11, e2);\n",
    "s3  = ref(f11, e3);\n",
    "s4  = ref(f11, e4);\n",
    "s5  = ref(f11, e5);\n",
    "s6  = ref(f11, e6);\n",
    "s7  = ref(f11, e7);\n",
    "s8  = ref(f11, e8);\n",
    "s9  = ref(f11, e9);\n",
    "s10 = ref(f11, e10);\n",
    "s11 = ref(f11, e11);\n",
    "s12 = ref(f11, e12);\n",
    "s13 = ref(f11, e13);\n",
    "s14 = ref(f11, e14);\n",
    "s15 = ref(f11, e15);\n",
    "s16 = ref(f11, e16);\n",
    "s17 = ref(f11, e17);\n",
    "s18 = ref(f11, e18);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# uncomment the following lines to see the reflection matrices\n",
    "#"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# show(\"s1 = \", s1);\n",
    "# show(\"s2 = \", s2);\n",
    "# show(\"s3 = \", s3);\n",
    "# show(\"s4 = \", s4);\n",
    "# show(\"s5 = \", s5);\n",
    "# show(\"s6 = \", s6);\n",
    "# show(\"s7 = \", s7);\n",
    "# show(\"s8 = \", s8);\n",
    "# show(\"s9 = \", s9);\n",
    "# show(\"s10 = \", s10);\n",
    "# show(\"s11 = \", s11);\n",
    "# show(\"s12 = \", s12);\n",
    "# show(\"s13 = \", s13);\n",
    "# show(\"s14 = \", s14);\n",
    "# show(\"s15 = \", s15);\n",
    "# show(\"s16 = \", s16);\n",
    "# show(\"s17 = \", s17);\n",
    "# show(\"s18 = \", s18);\n",
    "#"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\verb|delta11|\\phantom{\\verb!x!}\\verb|=| \\left(\\begin{array}{rrrrrrrrrrrr}\n",
       "9 & -2 & -2 & -2 & -2 & -2 & -2 & -2 & -2 & -4 & 0 & 0 \\\\\n",
       "4 & 0 & -1 & -1 & -1 & -1 & -1 & -1 & -1 & -2 & 0 & 0 \\\\\n",
       "4 & -1 & 0 & -1 & -1 & -1 & -1 & -1 & -1 & -2 & 0 & 0 \\\\\n",
       "4 & -1 & -1 & 0 & -1 & -1 & -1 & -1 & -1 & -2 & 0 & 0 \\\\\n",
       "4 & -1 & -1 & -1 & 0 & -1 & -1 & -1 & -1 & -2 & 0 & 0 \\\\\n",
       "4 & -1 & -1 & -1 & -1 & 0 & -1 & -1 & -1 & -2 & 0 & 0 \\\\\n",
       "4 & -1 & -1 & -1 & -1 & -1 & 0 & -1 & -1 & -2 & 0 & 0 \\\\\n",
       "-4 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 0 & 2 & 0 & 0 \\\\\n",
       "4 & -1 & -1 & -1 & -1 & -1 & -1 & 0 & -1 & -2 & 0 & 0 \\\\\n",
       "4 & -1 & -1 & -1 & -1 & -1 & -1 & -1 & -1 & -1 & 0 & 0 \\\\\n",
       "0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n",
       "0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1\n",
       "\\end{array}\\right)</script></html>"
      ],
      "text/plain": [
       "'delta11 = ' [ 9 -2 -2 -2 -2 -2 -2 -2 -2 -4  0  0]\n",
       "[ 4  0 -1 -1 -1 -1 -1 -1 -1 -2  0  0]\n",
       "[ 4 -1  0 -1 -1 -1 -1 -1 -1 -2  0  0]\n",
       "[ 4 -1 -1  0 -1 -1 -1 -1 -1 -2  0  0]\n",
       "[ 4 -1 -1 -1  0 -1 -1 -1 -1 -2  0  0]\n",
       "[ 4 -1 -1 -1 -1  0 -1 -1 -1 -2  0  0]\n",
       "[ 4 -1 -1 -1 -1 -1  0 -1 -1 -2  0  0]\n",
       "[-4  1  1  1  1  1  1  1  0  2  0  0]\n",
       "[ 4 -1 -1 -1 -1 -1 -1  0 -1 -2  0  0]\n",
       "[ 4 -1 -1 -1 -1 -1 -1 -1 -1 -1  0  0]\n",
       "[ 0  0  0  0  0  0  0  0  0  0  1  0]\n",
       "[ 0  0  0  0  0  0  0  0  0  0  0  1]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#\n",
    "# an infinite order orientation-reversing element in \\Gamma \\cap \\Delta\n",
    "#\n",
    "delta11 = s7*s8*s16;\n",
    "show(\"delta11 = \", delta11);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrr|r|r|r|r|r|r|r|r}\n",
       "-1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n",
       "\\hline\n",
       " 0 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n",
       "0 & 0 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n",
       "0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n",
       "\\hline\n",
       " 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n",
       "\\hline\n",
       " 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n",
       "\\hline\n",
       " 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n",
       "\\hline\n",
       " 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n",
       "\\hline\n",
       " 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n",
       "\\hline\n",
       " 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n",
       "\\hline\n",
       " 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n",
       "\\hline\n",
       " 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1\n",
       "\\end{array}\\right)</script></html>"
      ],
      "text/plain": [
       "[-1| 0  0  0| 0| 0| 0| 0| 0| 0| 0| 0]\n",
       "[--+--------+--+--+--+--+--+--+--+--]\n",
       "[ 0| 1  1  0| 0| 0| 0| 0| 0| 0| 0| 0]\n",
       "[ 0| 0  1  1| 0| 0| 0| 0| 0| 0| 0| 0]\n",
       "[ 0| 0  0  1| 0| 0| 0| 0| 0| 0| 0| 0]\n",
       "[--+--------+--+--+--+--+--+--+--+--]\n",
       "[ 0| 0  0  0| 1| 0| 0| 0| 0| 0| 0| 0]\n",
       "[--+--------+--+--+--+--+--+--+--+--]\n",
       "[ 0| 0  0  0| 0| 1| 0| 0| 0| 0| 0| 0]\n",
       "[--+--------+--+--+--+--+--+--+--+--]\n",
       "[ 0| 0  0  0| 0| 0| 1| 0| 0| 0| 0| 0]\n",
       "[--+--------+--+--+--+--+--+--+--+--]\n",
       "[ 0| 0  0  0| 0| 0| 0| 1| 0| 0| 0| 0]\n",
       "[--+--------+--+--+--+--+--+--+--+--]\n",
       "[ 0| 0  0  0| 0| 0| 0| 0| 1| 0| 0| 0]\n",
       "[--+--------+--+--+--+--+--+--+--+--]\n",
       "[ 0| 0  0  0| 0| 0| 0| 0| 0| 1| 0| 0]\n",
       "[--+--------+--+--+--+--+--+--+--+--]\n",
       "[ 0| 0  0  0| 0| 0| 0| 0| 0| 0| 1| 0]\n",
       "[--+--------+--+--+--+--+--+--+--+--]\n",
       "[ 0| 0  0  0| 0| 0| 0| 0| 0| 0| 0| 1]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "show(delta11.jordan_form())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#\n",
    "# the order of the reduction of \\delta_11 modulo (3)\n",
    "#\n",
    "matrix_reduction_order(delta11, 3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2 * 3"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#\n",
    "# its prime factors\n",
    "#\n",
    "factor(6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#\n",
    "# the order of the reduction of \\delta_11 modulo (4)\n",
    "#\n",
    "matrix_reduction_order(delta11, 4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2^2"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#\n",
    "# its prime factors\n",
    "#\n",
    "factor(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# dimension = 12\n",
    "#\n",
    "# basis vectors\n",
    "#\n",
    "v = matrix.identity(13);\n",
    "#\n",
    "# coefficients of the quadratic form\n",
    "#\n",
    "f12 = [-2] + 11*[1] + [2];"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# outer normals for the polytope P_12\n",
    "#\n",
    "e1 = -v[1] + v[2]; \n",
    "e2 = -v[2] + v[3];\n",
    "e3 = -v[3] + v[4];\n",
    "e4 = -v[4] + v[5];\n",
    "e5 = -v[5] + v[6];\n",
    "e6 = -v[6] + v[7];\n",
    "e7 = -v[7] + v[8];\n",
    "e8 = -v[8] + v[9];\n",
    "e9 = -v[9] + v[10];\n",
    "e10 = -v[10] + v[11];\n",
    "e11 = -v[11];\n",
    "e12 = -v[12];\n",
    "e13 = v[0] + 2*v[1] + v[12];\n",
    "e14 = v[0] + v[1] + v[2] + v[3] + v[4];\n",
    "e15 = 2*v[0] + v[1] + v[2] + v[3] + v[4] + v[5] + v[6] + v[7] + v[8] + v[12];\n",
    "e16 = 2*v[0] + v[1] + v[2] + v[3] + v[4] + v[5] + v[6] + v[7] + v[8] + v[9] + v[10];\n",
    "e17 = 3*v[0] + v[1] + v[2] + v[3] + v[4] + v[5] + v[6] + v[7] + v[8] + v[9] + v[10] + v[11] + 2*v[12];\n",
    "e18 = 3*v[0] + 2*(v[1] + v[2]) + v[3] + v[4] + v[5] + v[6] + v[7] + v[8] + v[9] + v[10] + v[11] + v[12];\n",
    "e19 = 3*(v[0] + v[1]) + v[2] + v[3] + v[4] + v[5] + v[6] + v[7] + v[8] + v[9] + v[10] + v[11];\n",
    "e20 = 5*v[0] + 2*(v[1] + v[2] + v[3] + v[4] + v[5] + v[6] + v[7] + v[8] + v[9] + v[10] + v[11] + v[12]);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# reflections in the hyperplanes of P_12\n",
    "#\n",
    "s1  = ref(f12, e1);\n",
    "s2  = ref(f12, e2);\n",
    "s3  = ref(f12, e3);\n",
    "s4  = ref(f12, e4);\n",
    "s5  = ref(f12, e5);\n",
    "s6  = ref(f12, e6);\n",
    "s7  = ref(f12, e7);\n",
    "s8  = ref(f12, e8);\n",
    "s9  = ref(f12, e9);\n",
    "s10 = ref(f12, e10);\n",
    "s11 = ref(f12, e11);\n",
    "s12 = ref(f12, e12);\n",
    "s13 = ref(f12, e13);\n",
    "s14 = ref(f12, e14);\n",
    "s15 = ref(f12, e15);\n",
    "s16 = ref(f12, e16);\n",
    "s17 = ref(f12, e17);\n",
    "s18 = ref(f12, e18);\n",
    "s19 = ref(f12, e19);\n",
    "s20 = ref(f12, e20);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# uncomment the following lines to see the reflection matrices\n",
    "#"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# show(\"s1 = \", s1);\n",
    "# show(\"s2 = \", s2);\n",
    "# show(\"s3 = \", s3);\n",
    "# show(\"s4 = \", s4);\n",
    "# show(\"s5 = \", s5);\n",
    "# show(\"s6 = \", s6);\n",
    "# show(\"s7 = \", s7);\n",
    "# show(\"s8 = \", s8);\n",
    "# show(\"s9 = \", s9);\n",
    "# show(\"s10 = \", s10);\n",
    "# show(\"s11 = \", s11);\n",
    "# show(\"s12 = \", s12);\n",
    "# show(\"s13 = \", s13);\n",
    "# show(\"s14 = \", s14);\n",
    "# show(\"s15 = \", s15);\n",
    "# show(\"s16 = \", s16);\n",
    "# show(\"s17 = \", s17);\n",
    "# show(\"s18 = \", s18);\n",
    "# show(\"s19 = \", s19);\n",
    "# show(\"s20 = \", s20);\n",
    "#"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\verb|delta12|\\phantom{\\verb!x!}\\verb|=| \\left(\\begin{array}{rrrrrrrrrrrrr}\n",
       "37 & -12 & -12 & -6 & -6 & -6 & -6 & -6 & -6 & -6 & -6 & -6 & -12 \\\\\n",
       "24 & -7 & -8 & -4 & -4 & -4 & -4 & -4 & -4 & -4 & -4 & -4 & -8 \\\\\n",
       "12 & -4 & -4 & -1 & -2 & -2 & -2 & -2 & -2 & -2 & -2 & -2 & -4 \\\\\n",
       "24 & -8 & -7 & -4 & -4 & -4 & -4 & -4 & -4 & -4 & -4 & -4 & -8 \\\\\n",
       "12 & -4 & -4 & -2 & -1 & -2 & -2 & -2 & -2 & -2 & -2 & -2 & -4 \\\\\n",
       "12 & -4 & -4 & -2 & -2 & -1 & -2 & -2 & -2 & -2 & -2 & -2 & -4 \\\\\n",
       "12 & -4 & -4 & -2 & -2 & -2 & -1 & -2 & -2 & -2 & -2 & -2 & -4 \\\\\n",
       "12 & -4 & -4 & -2 & -2 & -2 & -2 & -1 & -2 & -2 & -2 & -2 & -4 \\\\\n",
       "12 & -4 & -4 & -2 & -2 & -2 & -2 & -2 & -1 & -2 & -2 & -2 & -4 \\\\\n",
       "12 & -4 & -4 & -2 & -2 & -2 & -2 & -2 & -2 & -1 & -2 & -2 & -4 \\\\\n",
       "12 & -4 & -4 & -2 & -2 & -2 & -2 & -2 & -2 & -2 & -1 & -2 & -4 \\\\\n",
       "-12 & 4 & 4 & 2 & 2 & 2 & 2 & 2 & 2 & 2 & 2 & 1 & 4 \\\\\n",
       "12 & -4 & -4 & -2 & -2 & -2 & -2 & -2 & -2 & -2 & -2 & -2 & -3\n",
       "\\end{array}\\right)</script></html>"
      ],
      "text/plain": [
       "'delta12 = ' [ 37 -12 -12  -6  -6  -6  -6  -6  -6  -6  -6  -6 -12]\n",
       "[ 24  -7  -8  -4  -4  -4  -4  -4  -4  -4  -4  -4  -8]\n",
       "[ 12  -4  -4  -1  -2  -2  -2  -2  -2  -2  -2  -2  -4]\n",
       "[ 24  -8  -7  -4  -4  -4  -4  -4  -4  -4  -4  -4  -8]\n",
       "[ 12  -4  -4  -2  -1  -2  -2  -2  -2  -2  -2  -2  -4]\n",
       "[ 12  -4  -4  -2  -2  -1  -2  -2  -2  -2  -2  -2  -4]\n",
       "[ 12  -4  -4  -2  -2  -2  -1  -2  -2  -2  -2  -2  -4]\n",
       "[ 12  -4  -4  -2  -2  -2  -2  -1  -2  -2  -2  -2  -4]\n",
       "[ 12  -4  -4  -2  -2  -2  -2  -2  -1  -2  -2  -2  -4]\n",
       "[ 12  -4  -4  -2  -2  -2  -2  -2  -2  -1  -2  -2  -4]\n",
       "[ 12  -4  -4  -2  -2  -2  -2  -2  -2  -2  -1  -2  -4]\n",
       "[-12   4   4   2   2   2   2   2   2   2   2   1   4]\n",
       "[ 12  -4  -4  -2  -2  -2  -2  -2  -2  -2  -2  -2  -3]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#\n",
    "# an infinite order orientation-reversing element in \\Gamma \\cap \\Delta\n",
    "#\n",
    "delta12 = s2*s11*s18;\n",
    "show(\"delta12 = \", delta12);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.2679491924311227?, 3.732050807568878?]"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "delta12.eigenvalues()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#\n",
    "# the order of the reduction of \\delta_12 modulo (3)\n",
    "#\n",
    "matrix_reduction_order(delta12, 3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2 * 3"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#\n",
    "# its prime factors\n",
    "#\n",
    "factor(6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#\n",
    "# the order of the reduction of \\delta_12 modulo (4)\n",
    "#\n",
    "matrix_reduction_order(delta12, 4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2^2"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#\n",
    "# its prime factors\n",
    "#\n",
    "factor(4)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "SageMath 8.9",
   "language": "sage",
   "name": "sagemath"
  },
  "language": "python",
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.15"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
